using SS;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
namespace TVSGPP.func
{
	public class frmAddTracePatients1 : Form
	{
		private IContainer components = null;
		private Label label1;
		private Label label2;
		private Label label3;
		private Label label4;
		private Label label5;
		private Label label6;
		private Label label7;
		private Label label8;
		private Button btnClose;
		private Button btnSave;
		private Label label9;
		private Label label10;
		private Label label11;
		private Label label12;
		public TextBox txtPatientsName;
		public TextBox txtAddress;
		public TextBox txtAge;
		public TextBox txtDoctor;
		public TextBox txtDrugs;
		public TextBox txtDosage;
		public DateTimePicker dtpDateRep;
		public TextBox txtNumUsage;
		public TextBox txtPacket;
		public TextBox txtProvider;
		public DateTimePicker dtpExpiry;
		public ComboBox cbbGender;
		private Func objFunc = new Func();
		public string ID = "0";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.label1 = new Label();
			this.txtPatientsName = new TextBox();
			this.txtAddress = new TextBox();
			this.label2 = new Label();
			this.txtAge = new TextBox();
			this.label3 = new Label();
			this.label4 = new Label();
			this.label5 = new Label();
			this.txtDoctor = new TextBox();
			this.label6 = new Label();
			this.txtDrugs = new TextBox();
			this.label7 = new Label();
			this.txtDosage = new TextBox();
			this.label8 = new Label();
			this.dtpDateRep = new DateTimePicker();
			this.btnClose = new Button();
			this.btnSave = new Button();
			this.label9 = new Label();
			this.txtNumUsage = new TextBox();
			this.label10 = new Label();
			this.txtPacket = new TextBox();
			this.label11 = new Label();
			this.txtProvider = new TextBox();
			this.label12 = new Label();
			this.dtpExpiry = new DateTimePicker();
			this.cbbGender = new ComboBox();
			base.SuspendLayout();
			this.label1.AutoSize = true;
			this.label1.Location = new Point(221, 11);
			this.label1.Name = "label1";
			this.label1.Size = new Size(79, 15);
			this.label1.TabIndex = 0;
			this.label1.Text = "Người bệnh :";
			this.txtPatientsName.Location = new Point(303, 8);
			this.txtPatientsName.Name = "txtPatientsName";
			this.txtPatientsName.Size = new Size(242, 21);
			this.txtPatientsName.TabIndex = 1;
			this.txtAddress.Location = new Point(124, 35);
			this.txtAddress.Name = "txtAddress";
			this.txtAddress.Size = new Size(421, 21);
			this.txtAddress.TabIndex = 2;
			this.label2.AutoSize = true;
			this.label2.Location = new Point(69, 38);
			this.label2.Name = "label2";
			this.label2.Size = new Size(51, 15);
			this.label2.TabIndex = 2;
			this.label2.Text = "Địa chỉ :";
			this.txtAge.Location = new Point(124, 62);
			this.txtAge.Name = "txtAge";
			this.txtAge.Size = new Size(89, 21);
			this.txtAge.TabIndex = 3;
			this.label3.AutoSize = true;
			this.label3.Location = new Point(83, 65);
			this.label3.Name = "label3";
			this.label3.Size = new Size(37, 15);
			this.label3.TabIndex = 4;
			this.label3.Text = "Tuổi :";
			this.label4.AutoSize = true;
			this.label4.Location = new Point(240, 64);
			this.label4.Name = "label4";
			this.label4.Size = new Size(59, 15);
			this.label4.TabIndex = 6;
			this.label4.Text = "Giới tính :";
			this.label5.AutoSize = true;
			this.label5.Location = new Point(45, 11);
			this.label5.Name = "label5";
			this.label5.Size = new Size(75, 15);
			this.label5.TabIndex = 8;
			this.label5.Text = "Ngày tháng :";
			this.txtDoctor.Location = new Point(124, 89);
			this.txtDoctor.Name = "txtDoctor";
			this.txtDoctor.Size = new Size(421, 21);
			this.txtDoctor.TabIndex = 5;
			this.label6.AutoSize = true;
			this.label6.Location = new Point(3, 92);
			this.label6.Name = "label6";
			this.label6.Size = new Size(117, 15);
			this.label6.TabIndex = 10;
			this.label6.Text = "Bác sĩ / Chẩn đoán :";
			this.txtDrugs.Location = new Point(124, 116);
			this.txtDrugs.Name = "txtDrugs";
			this.txtDrugs.Size = new Size(421, 21);
			this.txtDrugs.TabIndex = 6;
			this.label7.AutoSize = true;
			this.label7.Location = new Point(22, 119);
			this.label7.Name = "label7";
			this.label7.Size = new Size(98, 15);
			this.label7.TabIndex = 12;
			this.label7.Text = "Thuốc, nồng độ :";
			this.txtDosage.Location = new Point(124, 143);
			this.txtDosage.Name = "txtDosage";
			this.txtDosage.Size = new Size(235, 21);
			this.txtDosage.TabIndex = 7;
			this.label8.AutoSize = true;
			this.label8.Location = new Point(52, 146);
			this.label8.Name = "label8";
			this.label8.Size = new Size(68, 15);
			this.label8.TabIndex = 14;
			this.label8.Text = "Liều dùng :";
			this.dtpDateRep.CustomFormat = "dd/MM/yyyy";
			this.dtpDateRep.Format = DateTimePickerFormat.Custom;
			this.dtpDateRep.Location = new Point(124, 8);
			this.dtpDateRep.Name = "dtpDateRep";
			this.dtpDateRep.Size = new Size(89, 21);
			this.dtpDateRep.TabIndex = 0;
			this.btnClose.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnClose.FlatStyle = FlatStyle.Flat;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new Point(454, 228);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(91, 26);
			this.btnClose.TabIndex = 13;
			this.btnClose.Text = "Thoát [ ESC ]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnSave.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnSave.FlatStyle = FlatStyle.Flat;
			this.btnSave.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSave.Location = new Point(322, 228);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(126, 26);
			this.btnSave.TabIndex = 12;
			this.btnSave.Text = "Lưu thông tin [ F6 ]";
			this.btnSave.UseVisualStyleBackColor = true;
			this.btnSave.Click += new EventHandler(this.btnSave_Click);
			this.label9.AutoSize = true;
			this.label9.Location = new Point(371, 146);
			this.label9.Name = "label9";
			this.label9.Size = new Size(79, 15);
			this.label9.TabIndex = 60;
			this.label9.Text = "Số lần dùng :";
			this.txtNumUsage.Location = new Point(454, 143);
			this.txtNumUsage.Name = "txtNumUsage";
			this.txtNumUsage.Size = new Size(91, 21);
			this.txtNumUsage.TabIndex = 8;
			this.label10.AutoSize = true;
			this.label10.Location = new Point(365, 173);
			this.label10.Name = "label10";
			this.label10.Size = new Size(85, 15);
			this.label10.TabIndex = 64;
			this.label10.Text = "Hạn sử dụng :";
			this.txtPacket.Location = new Point(124, 170);
			this.txtPacket.Name = "txtPacket";
			this.txtPacket.Size = new Size(235, 21);
			this.txtPacket.TabIndex = 9;
			this.label11.AutoSize = true;
			this.label11.Location = new Point(79, 173);
			this.label11.Name = "label11";
			this.label11.Size = new Size(41, 15);
			this.label11.TabIndex = 62;
			this.label11.Text = "Số lô :";
			this.txtProvider.Location = new Point(124, 197);
			this.txtProvider.Name = "txtProvider";
			this.txtProvider.Size = new Size(421, 21);
			this.txtProvider.TabIndex = 11;
			this.label12.AutoSize = true;
			this.label12.Location = new Point(28, 200);
			this.label12.Name = "label12";
			this.label12.Size = new Size(92, 15);
			this.label12.TabIndex = 66;
			this.label12.Text = "Hãng sản xuất :";
			this.dtpExpiry.CustomFormat = "dd/MM/yyyy";
			this.dtpExpiry.Format = DateTimePickerFormat.Custom;
			this.dtpExpiry.Location = new Point(454, 170);
			this.dtpExpiry.Name = "dtpExpiry";
			this.dtpExpiry.Size = new Size(91, 21);
			this.dtpExpiry.TabIndex = 10;
			this.cbbGender.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbGender.FlatStyle = FlatStyle.Popup;
			this.cbbGender.Font = new Font("Arial", 8.5f);
			this.cbbGender.FormattingEnabled = true;
			this.cbbGender.Items.AddRange(new object[]
			{
				"Nam",
				"Nữ"
			});
			this.cbbGender.Location = new Point(303, 61);
			this.cbbGender.Name = "cbbGender";
			this.cbbGender.Size = new Size(242, 22);
			this.cbbGender.TabIndex = 4;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.White;
			base.ClientSize = new Size(552, 262);
			base.Controls.Add(this.cbbGender);
			base.Controls.Add(this.dtpExpiry);
			base.Controls.Add(this.txtProvider);
			base.Controls.Add(this.label12);
			base.Controls.Add(this.label10);
			base.Controls.Add(this.txtPacket);
			base.Controls.Add(this.label11);
			base.Controls.Add(this.txtNumUsage);
			base.Controls.Add(this.label9);
			base.Controls.Add(this.btnSave);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.dtpDateRep);
			base.Controls.Add(this.txtDosage);
			base.Controls.Add(this.label8);
			base.Controls.Add(this.txtDrugs);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.txtDoctor);
			base.Controls.Add(this.label6);
			base.Controls.Add(this.label5);
			base.Controls.Add(this.label4);
			base.Controls.Add(this.txtAge);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.txtAddress);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.txtPatientsName);
			base.Controls.Add(this.label1);
			this.Cursor = Cursors.Hand;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Name = "frmAddTracePatients1";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = ".: Thông tin bệnh nhân";
			base.Load += new EventHandler(this.frmAddSideEffects_Load);
			base.KeyDown += new KeyEventHandler(this.frmAddSideEffects_KeyDown);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmAddTracePatients1()
		{
			Program.strConnectionString = this.objFunc.strConnectionString;
			this.InitializeComponent();
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
			try
			{
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = new SqlCommand("sp_TabPatients1", sqlConnection);
				sqlCommand.CommandType = CommandType.StoredProcedure;
				sqlCommand.Parameters.Add("ID", SqlDbType.Int);
				sqlCommand.Parameters.Add("dateRep", SqlDbType.DateTime);
				sqlCommand.Parameters.Add("patientsName", SqlDbType.NVarChar, 250);
				sqlCommand.Parameters.Add("address", SqlDbType.NVarChar, 300);
				sqlCommand.Parameters.Add("age", SqlDbType.Float);
				sqlCommand.Parameters.Add("gender", SqlDbType.Bit);
				sqlCommand.Parameters.Add("Doctor", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters.Add("drugs", SqlDbType.NVarChar, 200);
				sqlCommand.Parameters.Add("pID", SqlDbType.Int);
				sqlCommand.Parameters.Add("dosage", SqlDbType.NVarChar, 300);
				sqlCommand.Parameters.Add("numUsage", SqlDbType.Int);
				sqlCommand.Parameters.Add("packet", SqlDbType.VarChar, 50);
				sqlCommand.Parameters.Add("expiry", SqlDbType.DateTime);
				sqlCommand.Parameters.Add("provider", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters["ID"].Value = int.Parse(this.ID);
				sqlCommand.Parameters["dateRep"].Value = this.dtpDateRep.Value;
				sqlCommand.Parameters["patientsName"].Value = this.txtPatientsName.Text;
				sqlCommand.Parameters["address"].Value = this.txtAddress.Text;
				sqlCommand.Parameters["age"].Value = this.txtAge.Text;
				if (this.cbbGender.SelectedIndex == 0)
				{
					sqlCommand.Parameters["gender"].Value = "True";
				}
				else
				{
					sqlCommand.Parameters["gender"].Value = "False";
				}
				sqlCommand.Parameters["Doctor"].Value = this.txtDoctor.Text;
				sqlCommand.Parameters["drugs"].Value = this.txtDrugs.Text;
				sqlCommand.Parameters["pID"].Value = 0;
				sqlCommand.Parameters["dosage"].Value = this.txtDosage.Text;
				sqlCommand.Parameters["numUsage"].Value = this.txtNumUsage.Text;
				sqlCommand.Parameters["packet"].Value = this.txtPacket.Text;
				sqlCommand.Parameters["expiry"].Value = this.dtpExpiry.Value;
				sqlCommand.Parameters["Provider"].Value = this.txtProvider.Text;
				sqlCommand.ExecuteNonQuery();
				sqlConnection.Close();
				sqlConnection.Dispose();
				MessageBox.Show("Thông tin đã được lưu vào cở sở dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void frmAddSideEffects_Load(object sender, EventArgs e)
		{
			this.cbbGender.SelectedIndex = 0;
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmAddSideEffects_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
			else
			{
				if (e.KeyCode == Keys.F6)
				{
					this.btnSave.PerformClick();
				}
			}
		}
	}
}
